/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JDialogComments.java
 *
 * Created on 28/04/2011, 00:06:12
 */

package systole.view.tabs.results.comments;

import org.jdesktop.application.Action;

/**
 *
 * @author jmj
 */
public class JDialogComments extends javax.swing.JDialog {

    private ControllerComment controller;

    /** Creates new form JDialogComments
     * @param parent 
     * @param controller
     */
    public JDialogComments(java.awt.Frame parent, ControllerComment controller) {
        super(parent, true);
        initComponents();
        this.controller = controller;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLblTemplates = new javax.swing.JLabel();
        jCmbComments = new javax.swing.JComboBox();
        jBtnNewComments = new javax.swing.JButton();
        jBtnSearchComments = new javax.swing.JButton();
        jBtnAddComments = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTxtComments = new javax.swing.JTextArea();
        jBtnClear = new javax.swing.JButton();
        jBtnCancel = new javax.swing.JButton();
        jBtnOk = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getResourceMap(JDialogComments.class);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setModal(true);
        setName("Form"); // NOI18N
        setResizable(false);

        jLblTemplates.setText(resourceMap.getString("jLblTemplates.text")); // NOI18N
        jLblTemplates.setName("jLblTemplates"); // NOI18N

        jCmbComments.setEditable(true);
        jCmbComments.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        jCmbComments.setToolTipText(resourceMap.getString("jCmbComments.toolTipText")); // NOI18N
        jCmbComments.setName("jCmbComments"); // NOI18N

        jBtnNewComments.setIcon(resourceMap.getIcon("jBtnNewComments.icon")); // NOI18N
        jBtnNewComments.setToolTipText(resourceMap.getString("jBtnNewComments.toolTipText")); // NOI18N
        jBtnNewComments.setMaximumSize(new java.awt.Dimension(28, 28));
        jBtnNewComments.setMinimumSize(new java.awt.Dimension(28, 28));
        jBtnNewComments.setName("jBtnNewComments"); // NOI18N
        jBtnNewComments.setPreferredSize(new java.awt.Dimension(28, 28));
        jBtnNewComments.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnNewCommentsActionPerformed(evt);
            }
        });

        jBtnSearchComments.setIcon(resourceMap.getIcon("jBtnSearchComments.icon")); // NOI18N
        jBtnSearchComments.setToolTipText(resourceMap.getString("jBtnSearchComments.toolTipText")); // NOI18N
        jBtnSearchComments.setMaximumSize(new java.awt.Dimension(28, 28));
        jBtnSearchComments.setMinimumSize(new java.awt.Dimension(28, 28));
        jBtnSearchComments.setName("jBtnSearchComments"); // NOI18N
        jBtnSearchComments.setPreferredSize(new java.awt.Dimension(28, 28));
        jBtnSearchComments.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnSearchCommentsActionPerformed(evt);
            }
        });

        jBtnAddComments.setText(resourceMap.getString("jBtnAddComments.text")); // NOI18N
        jBtnAddComments.setToolTipText(resourceMap.getString("jBtnAddComments.toolTipText")); // NOI18N
        jBtnAddComments.setName("jBtnAddComments"); // NOI18N
        jBtnAddComments.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnAddCommentsActionPerformed(evt);
            }
        });

        jScrollPane1.setVerticalScrollBarPolicy(javax.swing.ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jTxtComments.setColumns(10);
        jTxtComments.setLineWrap(true);
        jTxtComments.setRows(5);
        jTxtComments.setWrapStyleWord(true);
        jTxtComments.setName("jTxtComments"); // NOI18N
        jScrollPane1.setViewportView(jTxtComments);

        jBtnClear.setText(resourceMap.getString("jBtnClear.text")); // NOI18N
        jBtnClear.setToolTipText(resourceMap.getString("jBtnClear.toolTipText")); // NOI18N
        jBtnClear.setName("jBtnClear"); // NOI18N
        jBtnClear.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBtnClearActionPerformed(evt);
            }
        });

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(systole.view.SystoleApp.class).getContext().getActionMap(JDialogComments.class, this);
        jBtnCancel.setAction(actionMap.get("cancel")); // NOI18N
        jBtnCancel.setText(resourceMap.getString("jBtnCancel.text")); // NOI18N
        jBtnCancel.setName("jBtnCancel"); // NOI18N

        jBtnOk.setAction(actionMap.get("ok")); // NOI18N
        jBtnOk.setText(resourceMap.getString("jBtnOk.text")); // NOI18N
        jBtnOk.setName("jBtnOk"); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLblTemplates)
                        .addGap(12, 12, 12)
                        .addComponent(jCmbComments, javax.swing.GroupLayout.PREFERRED_SIZE, 217, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBtnAddComments)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 115, Short.MAX_VALUE)
                        .addComponent(jBtnSearchComments, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBtnNewComments, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jBtnClear)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 301, Short.MAX_VALUE)
                        .addComponent(jBtnOk)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBtnCancel)))
                .addContainerGap())
        );

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jBtnCancel, jBtnOk});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jBtnAddComments, jBtnClear});

        layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jBtnNewComments, jBtnSearchComments});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(jCmbComments, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLblTemplates)
                    .addComponent(jBtnAddComments)
                    .addComponent(jBtnNewComments, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jBtnSearchComments, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(11, 11, 11)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 147, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jBtnCancel)
                    .addComponent(jBtnOk)
                    .addComponent(jBtnClear))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jBtnCancel, jBtnOk});

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jBtnAddComments, jBtnClear});

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jBtnNewComments, jBtnSearchComments});

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBtnClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnClearActionPerformed
        this.getjTxtComments().setText("");
}//GEN-LAST:event_jBtnClearActionPerformed

    private void jBtnNewCommentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnNewCommentsActionPerformed
      this.controller.newComment();
    }//GEN-LAST:event_jBtnNewCommentsActionPerformed

    private void jBtnSearchCommentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnSearchCommentsActionPerformed
        this.controller.search();
    }//GEN-LAST:event_jBtnSearchCommentsActionPerformed

    private void jBtnAddCommentsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBtnAddCommentsActionPerformed
       this.controller.addComment();
    }//GEN-LAST:event_jBtnAddCommentsActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBtnAddComments;
    private javax.swing.JButton jBtnCancel;
    private javax.swing.JButton jBtnClear;
    private javax.swing.JButton jBtnNewComments;
    private javax.swing.JButton jBtnOk;
    private javax.swing.JButton jBtnSearchComments;
    private javax.swing.JComboBox jCmbComments;
    private javax.swing.JLabel jLblTemplates;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTxtComments;
    // End of variables declaration//GEN-END:variables

    /**
     * @return the jCmbComments
     */
    public javax.swing.JComboBox getjCmbComments() {
        return jCmbComments;
    }

    /**
     * @return the jTxtComments
     */
    public javax.swing.JTextArea getjTxtComments() {
        return jTxtComments;
    }

    @Action
    public void ok() {
        this.controller.ok();
    }

    @Action
    public void cancel() {
        this.controller.cancel();
    }

  

    

}
